# -*- coding:utf-8 -*-
import platform
import os
import shutil
import sys
import time
import math
import json
import zipfile


sys.path.append("..")

import FileUtils


#获得文件md5
class FileMD5Helper:
    def __init__(self):
        self._list = []
        self._map = {}
        pass

    def getMD5List(self):
        return self._list

    def getMD5Map(self):
        return self._map

    def addAllFileMD5ByPath(self, dirPath):
        dirname = os.path.dirname(dirPath)
        _len = len(dirname)
        def callback(filepath,filename):
            self._list.append([filepath,FileUtils.md5(filepath)])
            pass

        FileUtils.diguiDir(dirPath,callback)
        
        #只要相对路径
        for data in self._list:  
            # print("data = ",data)
            absPath = data[0]
            md5 = data[1]
            _reletivePath = absPath[_len+1:]
            # print("_reletivePath = ",_reletivePath)
            self._map[_reletivePath] = {
                'path':_reletivePath,
                'md5':md5,
            }
        # print("self._map = ",self._map)

